//
//  LoginCoreNavigatorMap.swift
//  Pods
//
//  Created by eme on 2017/1/12.
//
//

import UIKit
import UtilCore
import URLNavigator
import BrandonCore

///登陆注册模块的路由
public struct LoginCoreNavigatorMap {
    
    public static func initialize() {
        ///跳转到Login_Vc
        Navigator.map("/login") { url, values in
            
            let loginVc:Login_Vc = JonSnowCore.storyboard.instantiateViewController()
            /// 需要手动的把ismodal标志为true
            loginVc.isModal = true
            let loginNav = UINavigationController(rootViewController: loginVc)
            Navigator.present(loginNav)
            return true
        }
        ///跳转到Forget_Vc
        Navigator.map("/forget") { url, values in
            let forgetVc:Forget_Vc = JonSnowCore.storyboard.instantiateViewController()
            Navigator.push(forgetVc)
            return true
        }
        Navigator.map("/resetpassword") { url, values in
            let resetPwdVc:ResetPwd_Vc = JonSnowCore.storyboard.instantiateViewController()
            resetPwdVc.phone = url.queryParameters["phone"]
            resetPwdVc.title = url.queryParameters["title"]
            Navigator.push(resetPwdVc)
            return true
        }
        ///跳转到Register_Vc
        Navigator.map("/register") { url, values in
            let registerVc:Register_Vc = JonSnowCore.storyboard.instantiateViewController()
            Navigator.push(registerVc)
            return true
        }
        ///跳转到Register_Vc
        Navigator.map("/successpage") { url, values in
            let successpageVc:SubmitSuccessPage_Vc = JonSnowCore.storyboard.instantiateViewController(withIdentifier: "SubmitSuccessPage_Vc") as! SubmitSuccessPage_Vc
            successpageVc.spid = url.queryParameters["spid"]
            Navigator.push(successpageVc)
            return true
        }
        ///跳转到AuthInfo_Vc
        Navigator.map("/authinfo") { url, values in
            switch AppData.appState {
            /// 当前状态为游客状态
            case .tourists:
                return  "login".openURL()
            /// 审核未认证的状态
            case .notAudit:
                if let spid = url.queryParameters["spid"]{
                    return "authinfopagevc".openURL(["spid":spid])
                }else{
                    return "authinfopagevc".openURL()
                }
                ///表示审核中
                ///表示审核失败
            ///已经审核通过
            default:
                return "certification".openURL()
            }
        }
        ///跳转到AuthInfo_Vc,这块主要是直供宝的认证资料界面和第一次认证界面为同一个界面
        Navigator.map("/authinfopagevc") { url, values in
            let registerDetailInfoVc:RegisterDetailInfo_Vc = JonSnowCore.storyboard.instantiateViewController()
            registerDetailInfoVc.spid = url.queryParameters["spid"]
            Navigator.push(registerDetailInfoVc)
            return true
            
        }
        ///跳转到Register_Vc
        Navigator.map("/registerdetailinfo") { url, values in
            let registerDetailInfoVc:RegisterDetailInfo_Vc = JonSnowCore.storyboard.instantiateViewController()
            registerDetailInfoVc.spid = url.queryParameters["spid"]
            registerDetailInfoVc.isFirst = true
            Navigator.push(registerDetailInfoVc)
            return true
        }
        ///跳转到ReviewDetailsPage_Vc
        Navigator.map("/reviewdetails") { url, values in
            let reviewDetailsPageVc:ReviewDetailsPage_Vc = JonSnowCore.storyboard.instantiateViewController()
            if let spid = url.queryParameters["spid"], spid.characters.count > 0{
                reviewDetailsPageVc.spid =  spid
                Navigator.push(reviewDetailsPageVc)
                return true
            }else{
                showMsg("店铺参数错误")
            }
            return false
        }
        
    }
    
    
}

